package com.chaosj.webmagic.dto;

import lombok.Data;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;

/**
 * @className: GuShiWenResponseDto
 * @description:
 * @author: caoyangjie
 * @date: 2021/8/11
 **/
@Data
@Accessors(chain = true)
public abstract class SearchResponseDto {
    protected List<Object> list = new ArrayList<>();

    /**
     * 添加对象
     * @param args
     */
    public abstract void addObject(String... args);

    @Override
    public String toString() {
        return buffer().toString();
    }

    /**
     * 对象格式化写出
     * @return
     */
    public StringBuffer buffer() {
        StringBuffer buffer = new StringBuffer();
        buffer.append("************************ start ******************************\n");
        if ( !list.isEmpty() ) {
            list.forEach(mj->buffer.append(mj));
        }
        buffer.append("************************ end ********************************\n");
        return buffer;
    }
}
